<div class="box-body table-responsive no-padding">
    <table class="table">
        <thead>
        <tr>
            <th>任务Id</th>
            <th>计划Id</th>
            <th>计划状态</th>
            <th>任务状态</th>
            <th>费用(元)</th>
            <th>运行次数</th>
            <th>输出文件数</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        @foreach($paginator as $row)
            <tr>
                <td>{{ $row->taskId }}</td>
                <td>{{ $row->planId }}</td>
                <td>{{ \App\Models\ZiNiao\PlansTasks::$_planStatus[$row->planStatus] }}</td>
                <td>{{ \App\Models\ZiNiao\PlansTasks::$_taskStatus[$row->taskStatus] }}</td>
                <td>{{ $row->cost }}</td>
                <td>{{ $row->runCount }}</td>
                <td>{{ $row->outPutCount }}</td>
                <td>{{ \App\Models\ZiNiao\PlansTasks::$_status[$row->status] }}</td>
                <td>
                    @if($row->status != 1)
                        <a href="javascript:void(0);" data-id="{{ $row->id }}" data-action="tasks" class="btn btn-xs btn-twitter grid-row-check">获取结果</a>
                    @else
                        <a href="javascript:void(0);"  class="btn btn-xs btn-twitter" disabled="disabled">获取结果</a>
                    @endif
                </td>
            </tr>
        @endforeach
        </tbody>
    </table>
</div>
<script language="JavaScript" type="text/javascript">
    $(function () {
        var _ajax = function (action,param) {
            $.ajax({
                method: 'post',
                url: '/xqc/ziniao/plans-tasks-ajax',
                data: {
                    _token: "{{ csrf_token() }}",
                    action:action,
                    param:param
                },
                success: function (data) {
                    if (typeof data === 'object') {
                        if (data.status) {
                            toastr.success('提交成功 !');
                            $.pjax.reload('#pjax-container');
                        } else {
                            swal(data.message, '', 'error');
                        }
                    }
                }
            });
        };
        //获取结果
        $('.grid-row-check').unbind('click').click(function(e) {
            e.preventDefault();
            var id = $(this).data('id');
            var action = $(this).data('action');
            _ajax(action,id);
        });
    });
</script>
